import { Component, OnInit, Input } from '@angular/core';
import { AppGlobalService } from 'src/app/shared/service/app-global.service';
import { EventService } from 'src/app/shared/service/event.service';
import { HttpService } from 'src/app/shared/service/http.service';
import { AlertController } from '@ionic/angular';
@Component({
  selector: 'app-statistics-customer-intention',
  templateUrl: './statistics-customer-intention.component.html',
  styleUrls: ['./statistics-customer-intention.component.scss'],
})
export class StatisticsCustomerIntentionComponent implements OnInit {
  @Input() tagData: any;
  constructor(
    private appGlobalService: AppGlobalService,
    private eventService: EventService,
    private httpService: HttpService,
    private alertController: AlertController
  ) {
  }

  lastChild: any;
  contentArray: any;

  ngOnInit() {
    try {
      const len = this.tagData.data.length;
      this.lastChild = this.tagData.data[len - 1];
      if (len > 0) {
        this.contentArray = [];
        for (let i = 1; i < len - 1; i++) {
          this.contentArray.push(this.tagData.data[i]);
        }
      }
    } catch (error) {
      console.log('error----->' + JSON.stringify(error));
    }


  }

  go(item) {
    if (item.link) {
      const params = {
        pageId: item.link.target,
        params: item.link.params,
        sessionId: localStorage.getItem("sessionId")
      };
      this.appGlobalService.goToForward(params);
    }
  }
}
